package com.panshi.controller.main;

import com.panshi.vo.FunctionVO;
import com.panshi.vo.InitMainVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import java.util.ArrayList;
import java.util.List;

@Controller
@Slf4j
public class MainController {

    public List<InitMainVO> init(){
        List<InitMainVO> mapList = new ArrayList<>();
        //网站管理
        List<FunctionVO> website = new ArrayList<>();
        website.add(new FunctionVO("友链管理",1001,"links/query"));
        website.add(new FunctionVO("关于我们",1002,"asme/query"));
        website.add(new FunctionVO("Banner",1003,"banner/query"));
        website.add(new FunctionVO("配置信息",1004,"config/query"));
        mapList.add((new InitMainVO("网站管理",website)));
        //资讯
        List<FunctionVO> zx = new ArrayList<>();
        zx.add(new FunctionVO("资讯分类",20010,"classify/query"));
        zx.add(new FunctionVO("资讯信息",20020,"message/query"));
        zx.add(new FunctionVO("资讯评论",20030,"discuss/query"));
        mapList.add(new InitMainVO("资讯管理",zx));
        //文章
        List<FunctionVO> wz = new ArrayList<>();
        wz.add(new FunctionVO("文章信息",3001,"queryess"));
        wz.add(new FunctionVO("文章审核",3002,"queryAudit"));
        mapList.add(new InitMainVO("文章管理",wz));
        //问答管理
        List<FunctionVO> wd = new ArrayList<>();
        wd.add(new FunctionVO("问题管理",4001,"question-home"));
        wd.add(new FunctionVO("提问审核",4002,"questionAudit-home"));
        wd.add(new FunctionVO("回答问题",4003,"answer-audit-home"));
        wd.add(new FunctionVO("回答评论",4004,"answer-discuss-home"));
        mapList.add(new InitMainVO("问答管理",wd));
        //用户管理
        List<FunctionVO> user = new ArrayList<>();
        user.add(new FunctionVO("用户管理",5001,"query"));
        user.add(new FunctionVO("用户留言",5002,"queryes"));
        mapList.add(new InitMainVO("用户管理",user));
        //系统管理
        List<FunctionVO> sysUser = new ArrayList<>();
        sysUser.add(new FunctionVO("系统用户",60010,"sys/user-all"));
        mapList.add(new InitMainVO("系统管理",sysUser));

        return mapList;
    }

    @RequestMapping(value = "/main-news",method = RequestMethod.GET)
    public ModelAndView queryAll(){

        ModelAndView mav = new ModelAndView("main/main");

        List<InitMainVO> mapList = init();

        mav.addObject("list",mapList);

        return mav;
    }

}
